package com.fun.library;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.TextView;

import com.fun.library.core.HHtml;
import com.fun.library.core.HtmlGetter;
import com.fun.library.interfase.IHtmlTagHandle;

/**
 * 作者: Created by AdminFun
 * 邮箱: 614484070@qq.com
 * 创建: 2018/12/25
 * 修改: 2018/12/25
 * 版本: v1.0.0
 * 描述: 自定义TextView，实现一些自定义功能，功能详见顶部注释
 */
@SuppressLint("AppCompatCustomView")
public class HtmlTextView extends TextView {

    private IHtmlTagHandle mTagHandle = null;

    public HtmlTextView(Context context) {
        super(context);
        this.initViews(context);
    }

    public HtmlTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.initViews(context);
    }

    public HtmlTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.initViews(context);
    }

    private void initViews(Context context) {

    }

    /**
     * 要显示的、包含HTML标签的字符串
     */
    public void setHtml(String html) {
        this.setText(HHtml.fromHtml(html, new HtmlGetter(this), mTagHandle));
    }
}